const url = 'http://www.domain.com/?name=henry&age=18#video'

const queryURLParams = (url, param) => {
  let result = {}
  url.replace(/#([^?#=&]+)/g, ($, $1) => (result['HASH'] = $1))
  url.replace(/([^?#=&]+)=([^?#=&]+)/g, ($, key, value) => (result[key] = value))
  return typeof param !== 'undefined' ? result[param] : result
}

// queryURLParams(url)
console.log(queryURLParams(url))
console.log(queryURLParams(url, 'name'))
